﻿using com.eforceglobal.crux.security.EncryptionAndHashing;
using com.eforceglobal.crux.security.EncryptionAndHashing.Enums;
using com.eforceglobal.crux.BusinessObjects;
using com.eforceglobal.crux.BusinessObjects.DatabaseQueries;

namespace com.eforceglobal.crux.BusinessFacades
{
    public class PasswordFacade
    {
        public void ResetPassword(int userid, string password, PasswordStorageType passwordstoragetype)
        {
            string userPassword = password;
            if (passwordstoragetype == PasswordStorageType.hashed)
                userPassword = Hasher.GetHash(userPassword);
            Queries query = new Queries();
            User dbUser = query.GetUser(userid);
            dbUser.Password = userPassword;
            query.SubmitChanges();
        }
    }
}
